<template>
  <ContentWrap>
    <el-descriptions :column="1" border>
      <el-descriptions-item label="供应商企业全称">
        {{ detailData.name }}
      </el-descriptions-item>
      <el-descriptions-item label="统一社会信用代码">
        {{ detailData.complainCode }}
      </el-descriptions-item>
      <el-descriptions-item label="注册人姓名">
        {{ detailData.registryName }}
      </el-descriptions-item>
      <el-descriptions-item label="注册人邮箱">
        {{ detailData.registryEmail }}
      </el-descriptions-item>
      <el-descriptions-item label="手机号码">
        {{ detailData.mobile }}
      </el-descriptions-item>
      <el-descriptions-item label="企业类型">
        <dict-tag :type="DICT_TYPE.COMPLAIN_TYPE" :value="detailData.type" />
      </el-descriptions-item>
      <el-descriptions-item label="纳税规模">
        <dict-tag :type="DICT_TYPE.TAX_SCALE" :value="detailData.taxScale" />
      </el-descriptions-item>
      <el-descriptions-item label="营业执照含三证合一">
        <UploadImg v-model="detailData.businessPic" :disabled="true"/>
      </el-descriptions-item>
      <el-descriptions-item label="法人姓名">
        {{ detailData.legalName }}
      </el-descriptions-item>
      <el-descriptions-item label="法人身份证">
        {{ detailData.legalNo }}
      </el-descriptions-item>
      <el-descriptions-item label="食品经营许可证">
        <UploadImg v-model="detailData.foodPic" :disabled="true"/>
      </el-descriptions-item>
      <el-descriptions-item label="税盘照片">
        <UploadImg v-model="detailData.taxPlatePic" :disabled="true"/>
      </el-descriptions-item>
      <el-descriptions-item label="注册资本(万)">
        {{ detailData.registeredCapital }}
      </el-descriptions-item>
      <el-descriptions-item label="企业联系人">
        {{ detailData.companyContact }}
      </el-descriptions-item>
      <el-descriptions-item label="企业联系人邮箱">
        {{ detailData.companyEmail }}
      </el-descriptions-item>
      <el-descriptions-item label="企业联系电话">
        {{ detailData.companyTelephone }}
      </el-descriptions-item>
      <el-descriptions-item label="企业经营范围">
        {{ detailData.companyScope }}
      </el-descriptions-item>
      <el-descriptions-item label="企业经营地址">
        {{ detailData.companyAddress }}
      </el-descriptions-item>
      <el-descriptions-item label="审核状态">
        <dict-tag :type="DICT_TYPE.COMPLAN_STATUS" :value="detailData.status" />
      </el-descriptions-item>
      <el-descriptions-item label="开户银行">
        {{ detailData.legalName }}
      </el-descriptions-item>
      <el-descriptions-item label="收款账号">
        {{ detailData.bankAccount }}
      </el-descriptions-item>
      <el-descriptions-item label="开户地址">
        {{ detailData.bankAddress }}
      </el-descriptions-item>
    </el-descriptions>
  </ContentWrap>
</template>
<script lang="ts" setup>
import { DICT_TYPE } from '@/utils/dict'
import { propTypes } from '@/utils/propTypes'
import {SupplierApi} from '@/api/erp/purchase/supplier'

defineOptions({ name: 'SupplierDetail' })

const { query } = useRoute() // 查询参数

const props = defineProps({
  id: propTypes.string.def(undefined)
})
const detailLoading = ref(false) // 表单的加载中
const detailData = ref<any>({}) // 详情数据
const queryId = query.id as unknown as number // 从 URL 传递过来的 id 编号

/** 获得数据 */
const getInfo = async () => {
  detailLoading.value = true
  try {
    detailData.value = await SupplierApi.getSupplier(props.id || queryId)
  } finally {
    detailLoading.value = false
  }
}
defineExpose({ open: getInfo }) // 提供 open 方法，用于打开弹窗

/** 初始化 **/
onMounted(() => {
  getInfo()
})
</script>
